%% 滤波器选择测试，选用不同的阙值规则进行滤波测试
clc;clear
horse_data = xlsread('E:\马的心电图特征提取\data.xlsx','sheet1');   %读取马的心跳数据
N = 3; %小波变换级别
%% 存储每匹马的数据
horse_1 = horse_data(1,:);       %第1匹马
horse_2 = horse_data(2,:);       %第2匹马
horse_3 = horse_data(3,:);       %第3匹马
horse_4 = horse_data(4,:);       %第4匹马
horse_5 = horse_data(5,:);       %第5匹马
horse_6 = horse_data(6,:);       %第6匹马
horse_7 = horse_data(7,:);       %第7匹马
horse_8 = horse_data(8,:);       %第8匹马
horse_9 = horse_data(9,:);       %第9匹马
%% 以第一匹马进行滤波器选择测试
figure('name','原图')
x1 = 1:1:255;
plot(x1,horse_1);
axis([0 256 0 123]);
title('原图')
%% 阙值规则：‘rigrsure’，采用Stein无偏似然估计；
figure('name','阙值调整：mln')
XD1 = wden(horse_1,'rigrsure','s','mln',N,'db3');
subplot(4,2,1);plot(x1,XD1);axis([0 256 0 123]);
title('rigrsure-S')
XD2 = wden(horse_1,'rigrsure','h','mln',N,'db3');
subplot(4,2,2);plot(x1,XD2);axis([0 256 0 123]);
title('rigrsure-h')
%% 阙值规则：‘heursure’，采用启发式阈值选择；
XD3 = wden(horse_1,'heursure','s','mln',N,'db3');
subplot(4,2,3);plot(x1,XD3);axis([0 256 0 123]);
title('heursure-S')
XD4 = wden(horse_1,'heursure','h','mln',N,'db3');
subplot(4,2,4);plot(x1,XD4);axis([0 256 0 123]);
title('heursure-h')
%% 阙值规则：‘sqtwolog’，采用通用阈值
XD5 = wden(horse_1,'sqtwolog','s','mln',N,'db3');
subplot(4,2,5);plot(x1,XD5);axis([0 256 0 123]);
title('sqtwolog-S')
XD6 = wden(horse_1,'sqtwolog','h','mln',N,'db3');
subplot(4,2,6);plot(x1,XD6);axis([0 256 0 123]);
title('sqtwolog-h')
%% 阙值规则：'minimaxi’，采用极大值极小值进行阈值选择。
XD7 = wden(horse_1,'minimaxi','s','mln',N,'db3');
subplot(4,2,7);plot(x1,XD7);axis([0 256 0 123]);
title('minimaxi-S')
XD8 = wden(horse_1,'minimaxi','h','mln',N,'db3');
subplot(4,2,8);plot(x1,XD8);axis([0 256 0 123]);
title('minimaxi-h')
%% -------------------------------------------------

%% 阙值调整：sln
figure('name','阙值调整：sln')
XD1 = wden(horse_1,'rigrsure','s','sln',N,'db3');
subplot(4,2,1);plot(x1,XD1);axis([0 256 0 123]);
title('rigrsure-S')
XD2 = wden(horse_1,'rigrsure','h','sln',N,'db3');
subplot(4,2,2);plot(x1,XD2);axis([0 256 0 123]);
title('rigrsure-h')

XD3 = wden(horse_1,'heursure','s','sln',N,'db3');
subplot(4,2,3);plot(x1,XD3);axis([0 256 0 123]);
title('heursure-S')
XD4 = wden(horse_1,'heursure','h','sln',N,'db3');
subplot(4,2,4);plot(x1,XD4);axis([0 256 0 123]);
title('heursure-h')

XD5 = wden(horse_1,'sqtwolog','s','sln',N,'db3');
subplot(4,2,5);plot(x1,XD5);axis([0 256 0 123]);
title('sqtwolog-S')
XD6 = wden(horse_1,'sqtwolog','h','sln',N,'db3');
subplot(4,2,6);plot(x1,XD6);axis([0 256 0 123]);
title('sqtwolog-h')

XD7 = wden(horse_1,'minimaxi','s','sln',N,'db3');
subplot(4,2,7);plot(x1,XD7);axis([0 256 0 123]);
title('minimaxi-S')
XD8 = wden(horse_1,'minimaxi','h','sln',N,'db3');
subplot(4,2,8);plot(x1,XD8);axis([0 256 0 123]);
title('minimaxi-h')
%% ----------------------------------------------
%% 小波信号：db8
figure('name','小波信号：db8')
XD1 = wden(horse_1,'rigrsure','s','sln',N,'db8');
subplot(4,2,1);plot(x1,XD1);axis([0 256 0 123]);
title('rigrsure-S')
XD2 = wden(horse_1,'rigrsure','h','sln',N,'db8');
subplot(4,2,2);plot(x1,XD2);axis([0 256 0 123]);
title('rigrsure-h')

XD3 = wden(horse_1,'heursure','s','sln',N,'db8');
subplot(4,2,3);plot(x1,XD3);axis([0 256 0 123]);
title('heursure-S')
XD4 = wden(horse_1,'heursure','h','sln',N,'db8');
subplot(4,2,4);plot(x1,XD4);axis([0 256 0 123]);
title('heursure-h')

XD5 = wden(horse_1,'sqtwolog','s','sln',N,'db8'); %调试修改
subplot(4,2,5);plot(x1,XD5);axis([0 256 0 123]);
title('sqtwolog-S')
XD6 = wden(horse_1,'sqtwolog','h','sln',N,'db8');
subplot(4,2,6);plot(x1,XD6);axis([0 256 0 123]);
title('sqtwolog-h')

XD7 = wden(horse_1,'minimaxi','s','sln',N,'db8');
subplot(4,2,7);plot(x1,XD7);axis([0 256 0 123]);
title('minimaxi-S')
XD8 = wden(horse_1,'minimaxi','h','sln',N,'db8');
subplot(4,2,8);plot(x1,XD8);axis([0 256 0 123]);
title('minimaxi-h')











